pub struct StoppingTimeCalculation{
    time_to_react:f64,
    driver_decel:f64,
    time_margin:f64,
}

impl Default for  StoppingTimeCalculation {
    fn default() -> Self {
        StoppingTimeCalculation { 
            time_to_react:1.2,
            driver_decel:4.0,
            time_margin:0.0,
        }
    }
}

impl StoppingTimeCalculation {
    pub fn new()->Self{
        StoppingTimeCalculation{
            ..Default::default()
        }
    }
    pub fn get_driver_decel(&self)->&f64{
        &self.driver_decel
    }
    pub fn get_time_to_react(&self)->&f64{
        &self.time_to_react
    }
    pub fn get_time_margin(&self)->&f64{
        &self.time_margin
    }
    pub fn set_driver_decel(& mut self,driver_decel:f64){
        self.driver_decel=driver_decel;
    }
    pub fn set_time_to_react(& mut self,time_to_react:f64){
        self.time_to_react=time_to_react;
    }
    pub fn set_time_margin(&mut self,time_margin:f64){
        self.time_margin=time_margin;
    }


    pub fn calculation(
        &self,
        ego_velocity:f64,
        pb1_decel:f64,
        pb2_decel:f64,
        fb_decel:f64,

    )->(f64,f64,f64,f64){
        let fcw_stopping_time=ego_velocity/self.driver_decel+self.time_to_react;
        let pb1_stopping_time=ego_velocity/pb1_decel+self.time_margin;
        let pb2_stopping_time=ego_velocity/pb2_decel+self.time_margin;
        let fb_stopping_time=ego_velocity/fb_decel+self.time_margin;
        (fcw_stopping_time,pb1_stopping_time,pb2_stopping_time,fb_stopping_time)

    }




}